package com.vs.model;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class ValidateForm extends ActionForm {

	private static final long serialVersionUID = -8480955548569143706L;

	private String userName;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		System.out.println("validate from validateForm called");
		ActionErrors errors = new ActionErrors();
		System.out.println("user=" + this.getUserName());
		if (this.getUserName() == null || "".equals(this.getUserName())) {
			errors.add("name", new ActionMessage("errors.required", "name"));
		}

		return errors;
	}
}
